<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入人家提供的依赖包 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.3.3/echarts.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 1000px;
            height: 400px;
            border: 1px solid black;
        }
    </style>
</head>

<body>
    <!-- 准备一个具有一定高度的容器 -->
    <div class="box"></div>
</body>

</html>
<script>
    //初始化echarts实例
    let mycharts = echarts.init(document.querySelector('.box'));
    //通过echarts实例方法setOption方法初始化各种图形图标
    //准备配置对象
    let options = {
        title: {
            text: '饼图',
        },
        xAxis: {},
        yAxis: {},
        series: {
            type: 'pie',
            data: [{name:"苹果",value:100,itemStyle:{color:'red'}},{name:"鸭梨",value:200,itemStyle:{color:'orange'}},{name:"香蕉",value:300,itemStyle:{color:'yellowgreen'}}],
           //饼图宽度
           width:300,
           height:300,
           radius:50,
           left:'center',
           top:'center',
           //设置每一个饼图颜色
           colorBy:'data',
           //文本标签
           label:{
               show:true,
            //    position:'inside',//图形内部
           },
           //引导线
           labelLine:{
               lineStyle:{
                   color:'red'
               }
           }
        }
    }
    //设置配置项
    mycharts.setOption(options);
</script>